<!DOCTYPE html>
<html>

	<head lang="en">
		<title>找攻略</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/strategy.css" />
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
		<script src="/js/plugins/dialog2/dialog.min.js"></script>
		<script>
			$(function () {
                var cbId="";
                //分页临时变量
                var currentPage = 2;
			    //推荐------------------------------------------------
				$.get("/lmTicketCatalogBigs/load",{state:1},function (data) {

                    var html='';
                    var content='';
                    $.each(data,function (index,item) {
                       // console.log(item.id);
                        html+=
                    '<li class="nav-item"><a data-id="'+item.id+'" class="nav-link" id="pills-'+item.id+'-tab" data-toggle="pill" href="#pills-'+item.id+'">'+item.name+'</a></li>'

						content+='<div class="tab-pane fade" id="pills-'+item.id+'"></div>';
                    })
                    $("#pills-tab").append(html);
                    $("#pills-tabContent").append(content);

                    //给分类绑定点击事件
                    $(".nav-link").click(function () {
                        cbId=$(this).data("id");
                        if(cbId){
                            $.get("/lmTicketCatalogBigs/"+cbId+"/childs",function (data) {
                                //console.log(data);
                                $("#pills-"+cbId).html(data);
                                currentPage = 2;
                            },"html");
						}
                    });
                })


				//分页相关
                //因为下一时,jrender解析数据会见到上一页数据丢失
                var dataList = []; //分页缓存数据
                var totalPage = 2;  //总页数
                //分页
                function query() {
                    if(cbId){
                        $.get("/lmTicketCatalogBigs/"+cbId+"/childs",{currentPage:currentPage,pageSize:8},function (data) {
                            //在第一页全部攻略后面拼接出第二页
                            var html='';
                            $.each(data.list,function (index,item) {
                                if(item.detail){
                                    html+='<div class="col-6 mb">' +
                                        '                <a href="/landmarkDetail.html?id='+item.detail.id+'">' +
                                        '                    <img class="float-left " src="'+item.detail.coverUrl+'">' +
                                        '                    <div class="classify-text">' +
                                        '                        <span>'+item.name+'</span>' +
                                        '                    </div>' +
                                        '                </a>' +
                                        '            </div>';
								}
                            })
                            $(".classify").append(html)


                            currentPage += 1;
                            totalPage = data.pages;
                        },"json")
					}
                }

                //屏幕滚动事件
                $(window).scroll(function () {
                    if ($(window).height() + $(document).scrollTop() + 1 >= $(document).height()) {
                        //限制当前页数小于等于总页数,翻页
                        if (currentPage <= totalPage) {
                            query();
                        } else {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '到底了...',
                                autoClose: 2500,
                                position: 'bottom'  // center: 居中; bottom: 底部
                            });
                        }
                    }
                });




                    //获取攻略推荐游记
				$.get("/lmTicketCatalogBigs/1",function (data) {
                    //console.log(data);
					$(".commend").renderValues(data[0],{
					    setHref:function (item,value) {
					        $(item).attr("href",$(item).data("href")+value);
                        }
					})
                })

				//所有当季推荐
				$.get("/lmTicketCatalogBigs/special",{state:2,pageSize:0},function (data) {
                    //console.log(data);
                    $(".strategyCommend").renderValues(data,{
                        setHref:function (item,value) {
                            $(item).attr("href",$(item).data("href")+value)
                        }
					});
                })
            });
		</script>
	</head>

	<body>
	<div class="search-head">
		<div class="row nav-search">
			<div class="col-2">
				<a href="index.html">
					<span><i class="fa fa-chevron-left fa-2x"></i></span>
				</a>
			</div>
			<div class="col-10">
				<div class="input-group-sm search">
					<input class="form-control searchBtn" placeholder="找门票">
				</div>
			</div>
		</div>
	</div>


	<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
		<li class="nav-item">
			<a class="nav-link active show" id="pills-top-tab" data-toggle="pill" href="#pills-top">
				<span style="font-weight: bold;">推荐</span>
			</a>
		</li>

	</ul>


	<div class="tab-content" id="pills-tabContent">
		<div class="tab-pane fade active show" id="pills-top">
			<div class="container commend">
				<a data-href="/landmarkContent.html?id=" render-fun="setHref" render-key="id">
					<img render-src="coverURL">
					<p render-html="title"></p>
				</a>
			</div>
			<hr>
			<div class="container strategyCommend">
				<h6>专题推荐</h6>
				<div class="row hot" render-loop="list">

					<div class="col-4">
						<a data-href="landmarkDetail.html?id=" render-fun="setHref" render-key="list.detail.id">
							<img render-src="list.detail.coverUrl">
							<p render-html="list.name"></p>
						</a>
					</div>

				</div>
			</div>
		</div>
	</div>

	</body>

</html>